<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>手风琴(纯css)</title>
    <style>
      body {
        /* 背景渐变 */
        background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);
        font-family: Arial, sans-serif;
      }
      .box {
        width: 500px;
        margin: 100px 200px;
      }

      .vertical {
        width: 100px;
        margin: 100px 200px;
      }

      .item {
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        height: 60px;
        width: 60px;
        margin: 4px 8px;
        overflow: hidden;
        background: #fff;
        border-radius: 30px;
        box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.24);
        transition: all 0.5s;
        cursor: pointer;
      }

      .item:hover {
        width: 180px;
      }

      .icon {
        width: 60px;
        height: 60px;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 30px;
        font-size: 28px;
        position: relative;
        transition: all 0.5s;
        pointer-events: none;
      }

      .icon::after {
        position: absolute;
        content: '';
        width: fit-content;
        word-break: keep-all;
        font-size: medium;
        left: 72px;
        pointer-events: auto;
        cursor: pointer;
      }

      /* 颜色和内容配置 */
      .items-config {
        display: none; /* 隐藏配置项 */
      }

      .item:nth-child(1) .icon {
        color: #dd3b32;
      }

      .item:nth-child(1) .icon::after {
        content: '我是红桃';
      }

      .item:nth-child(2) .icon {
        color: #1a1a1a;
      }

      .item:nth-child(2) .icon::after {
        content: '我是黑桃';
      }

      .item:nth-child(3) .icon {
        color: #fb1c17;
      }

      .item:nth-child(3) .icon::after {
        content: '我是方块';
      }

      .item:nth-child(4) .icon {
        color: #090b0a;
      }

      .item:nth-child(4) .icon::after {
        content: '我是梅花';
      }

      /* 悬浮效果 */
      .item:hover .icon {
        background-color: rgba(255, 192, 203, 0.5); /* 使用rgba实现透明背景色 */
      }
    </style>
  </head>

  <body>
    <!-- 横着的手风琴 -->
    <div class="box">
      <div class="item">
        <div class="icon">♥</div>
      </div>
      <div class="item">
        <div class="icon">♠</div>
      </div>  
      <div class="item">
        <div class="icon">♦</div>
      </div>
      <div class="item">
        <div class="icon">♣</div>
      </div>
    </div>

    <!-- 竖着的手风琴 -->
    <div class="vertical">
      <div class="item">
        <div class="icon">♥</div>
      </div>
      <div class="item">
        <div class="icon">♠</div>
      </div>
      <div class="item">
        <div class="icon">♦</div>
      </div>
      <div class="item">
        <div class="icon">♣</div>
      </div>
    </div>
  </body>
</html>
